{extend name="public/base" /}
{block name="style"}<link href="__LIB__/fileinput/css/fileinput.min.css" rel="stylesheet" /> {/block}
 {block name="body"}
<div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('web/index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li>
			<a href="{:url('index')}">商品管理</a>
		</li>
		<li><strong>导入商品</strong></li>
	</ol>
</div>
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<form id="myForm" class="form-horizontal m-t" method="post" action="{:url('padd_ok')}" enctype="multipart/form-data" onsubmit="return toVaild()">
		<div class="form-group">
			<label class="col-sm-3 control-label">导入文件</label>
			<div class="input-group col-sm-4">
				<input type="file" name="myfile" id="myfile" value=""/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label"></label>
			<div class="input-group col-sm-4">
				只允许导入csv格式的文件，请先<a href="{:url('dc',['data'=>'0'])}">下载样板</a>。
			</div>
		</div>				
		<div class="form-group">
			<div class="col-sm-4 col-sm-offset-3">
				<button class="btn btn-primary" type="submit" id="submit"><i class="fa fa-save"></i> 导入</button>&nbsp;&nbsp;
				<a href="{:url('index')}" class="btn btn-danger"><i class="fa fa-arrow-left"></i> 返回 </a>
			</div>
		</div>   	
		<div class="form-group" {if $list == '1'}style="display: none"{/if}>
			{if $list !== '1'}
			<label class="col-sm-3 control-label">商品名称已存在:</label>
			<div class="input-group col-sm-4" style="margin-top: 8px;">
			{volist name="list" id='ad'}
			{$ad}，
			{/volist}
			{/if}
			</div>
		</div>
		<div class="form-group" {if $list1 == '1'}style="display: none"{/if}>
			{if $list1 !== '1'}
			<label class="col-sm-3 control-label">商品编码已存在:</label>
			<div class="input-group col-sm-4" style="margin-top: 8px;">
			{volist name="list1" id='ad'}
			{$ad}，
			{/volist}
			{/if}
			</div>
		</div>
		</form>
	</div>
</div>
{/block} {block name="script"}
<script src="__JS__/jquery.form.js"></script>
<script src="__LIB__/validate/jquery.validate.min.js"></script>
<script src="__LIB__/validate/messages_zh.min.js"></script>
<script src="__LIB__/validate/add_validate.min.js"></script>
<script src="__LIB__/fileinput/js/fileinput.min.js"></script>
<script src="__LIB__/fileinput/js/locales/zh.js"></script>
<script src="__LIB__/ueditor/ueditor.config.js" type="text/javascript"></script>
<script src="__LIB__/ueditor/ueditor.all.js" type="text/javascript"></script>
 <script>
   $(function() {
		$("#myForm").validate({
			rules: {
				myfile: "required"
			},
			messages: {
				myfile: ICON.error + "请选择文件"
			},
			submitHandler: function(form) {
				ajaxForm();
			}
			
		});
	});
</script>
<script>
     function toVaild(){
        var val = document.getElementById("myfile").value;
        if(val == ""){
             layer.msg("请添加文件");
             return false;
         }
       
     }
</script>
{/block}